using UnityEngine;
using System.Collections;

public class guiScore : MonoBehaviour {
	public static int currentScore = 0;
	private int visibleScore = 0;
	private int failScore = 0;
	public int numFails = 3;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		failCheck();
	}
	
	void OnGUI() {
		GUILayout.BeginArea(new Rect(10,10,100,200 ));
		GUILayout.Box ( visibleScore.ToString () );
    	GUILayout.EndArea ();
		GUILayout.BeginArea(new Rect(35,35,50,20));
		GUILayout.Box("Score");
		GUILayout.EndArea();
		GUILayout.BeginArea(new Rect(120,10,100,200));
		GUILayout.Box(numFails.ToString());
		GUILayout.EndArea();
		GUILayout.BeginArea(new Rect(135,35,67,20));
		GUILayout.Box("Chances");
		GUILayout.EndArea();
	}
	// Increment Score
	public void IncrementScore() {
    	visibleScore += 1;
		failScore += 1;
	}
	
	public void failCheck() {
		if(BallMove.objectDestroyed) {
			numFails -= 1;
			failScore = 0;
			visibleScore--;
		}
		if(failScore >= 100) {
			if(numFails <=2) {
				numFails++;
			}
			failScore = 0;
		}
		if(numFails == 0) {
			currentScore = visibleScore;	
		}
	}
}
